$(function(){

		$('.landing-citybar').click(function(){
			
			setTimeout(function(){
				$('#muti-aois,#muti-aois .cities').show();
			},600)

		});
			

			

		

		$(document).click(function(e){
			$('#muti-aois').hide();
			$('#muti-aois .aois').hide();
			e.stopPropagation();
		});

		$('.cities-group dd li a').click(function(){
			var did = $(this).attr('data-cityid');
		$('.landing-citybar .current-city').attr('data-name',$(this).html());
		$('.landing-citybar .current-city').attr('data-code',$(this).attr('data-cityid'));
		$('.landing-citybar .current-city').html($(this).html());

			$.ajax({
            url:CONTROLLER+'/ajax_district',
            type:"post",
            data:{'did':did},
            dataType:"json",
            success:function(data){
            	var str = '<div class="aois" data-node="cities">';
            	$.each(data,function(k,v){
            		// alert(v.pid);
            		
					
					str += '<dl class="aoi-group">\
							  <dt>'+v.dname+'</dt>\
							  <dd>\
							  	<ul>';
					if(v.son){
						$.each(v.son,function(key,value){
						str += '<li>\
							<a href="'+MODULE+'/Storelist/index/did/'+value.did+'" data-node="nav_aoi" title="'+value.dname+'">'+value.dname+'</a>\
							 </li>';
							});
					}
					
					str +='</ul>\
							 </dd>\
							 </dl>';
							
            	});
            
            	str += '</div>';
             
            	$('.cities').after(str);
            	$('#muti-aois').show();
            	$('#muti-aois .cities').hide();
            }
        });
		
		});


		$('#search-con').keyup(function(){
		var did = $('.landing-citybar .current-city').attr('data-code');
		var value = $('#search-con').val();

		if(value.length<1){
			$('#search').hide();
		}

		if(value.length>0){
			$.ajax({
        	url:WEB+'?c=Index&a=ajax_inquire',
            type:"post",
            data:{'did':did,'value':value},
            dataType:"json",	
            success:function(data){
            	var str ='';
            	if(data){
            	$.each(data,function(k,v){
            		str+='<li>\
					<div class="storeName">'+v.stname+'</div>\
					<div class="district">'+v.storesite+'</div>\
					<div class="addr-icon"></div>\
					</li>';
            	});
            	$('#search ul').append(str);
            	$('#search').show();
			}
       	}

            });

            }
		})
 })